package com.example.service.impl;

import com.example.mapper.MuseumMapper;
import com.example.pojo.entity.Museum;
import com.example.service.MuseumService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MuseumServiceImpl implements MuseumService {


    @Autowired
    MuseumMapper museumMapper;


    @Override
    public void insert(Museum museum) {

        museumMapper.insert(museum);
    }

    @Override
    public void updateById(Museum museum) {

        museumMapper.updateById(museum);
    }

    @Override
    public void removeById(Integer id) {

        museumMapper.removeById(id);
    }

    @Override
    public void removeBatchByIds(List<Integer> ids) {

        for (Integer id : ids){
            museumMapper.removeById(id);
        }
    }

    @Override
    public Museum getById(Integer id) {
        Museum museum = museumMapper.getById(id);
        return museum;
    }

    @Override
    public PageInfo<Museum> selectByPage(Integer pageNum, Integer pageSize, String name) {
        PageHelper.startPage(pageNum, pageSize);
        List<Museum> list = museumMapper.selectByPage(name);
        return new PageInfo<>(list);
    }
}
